package com.example.comiccenter.controller;


import com.example.comiccenter.domain.ComicPage;
import com.example.comiccenter.service.ComicPageService;
import com.example.comiccenter.utils.ResultData;
import com.example.comiccenter.utils.SearchBean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comicPage")
public class PageController {

    @Resource
    private ComicPageService pageService;

    @PostMapping("/getAllPage")
    public ResultData selectPage(@RequestBody SearchBean<ComicPage> searchBean){
        return pageService.getAllPage(searchBean);
    }

    //添加comic
    @PostMapping("/addComicPage")
    public ResultData addComicPage(@RequestPart ComicPage comicPage, MultipartFile coverFile){
//        System.out.println("插入page："+page);
        return pageService.addPage(comicPage,coverFile);
    }

    //删除page
    @PostMapping("/deleteComicPage")
    public ResultData deleteComicPage(@RequestBody ComicPage page){
//        System.out.println("删除page："+page);

        return pageService.deletePage(page);
    }

    //更新page
    @PostMapping("/updateComicPage")
    public ResultData updateComicPage(@RequestPart ComicPage comicPage, MultipartFile coverFile){
//        System.out.println("修改page："+page);
        return pageService.updatePage(comicPage,coverFile);
    }
}
